Engine.Vector2 = function(x,y){
    this.x = x;
    this.y = y;
};

Engine.Vector2.prototype = (function(){
    return {
        plus : function (v){
            return new Engine.Vector2(this.x + v.x,this.y + v.y);
        },
        minus : function (v){
            return new Engine.Vector2(this.x - v.x,this.y - v.y);
        },
        normalize: function (){
            var d = Math.sqrt(dot(this));
            return new Engine.Vector2(this.x/d,this.y/d);
        },
        dot : function (v){
            return this.x * v.x + this.y * v.y;
        },
        multiply : function (n){
            return new Engine.Vector2(this.x* n,this.y* n);
        }
    };
})();

Engine.Vector2.one = new Engine.Vector2(1,1);

Engine.Vector3 = function(x,y,z){
    this.x = x;
    this.y = y;
    this.z = z;
};

Engine.Vector3.prototype = (function(){
    return {
        plus : function (v){
            return new Engine.Vector3(this.x + v.x,this.y + v.y,this.z + v.z);
        },
        minus : function (v){
            return new Engine.Vector3(this.x - v.x,this.y - v.y,this.z - v.z);
        },
        normalize: function (){
            var d = Math.sqrt(this.dot(this));
            return new Engine.Vector3(this.x/d,this.y/d,this.z/d);
        },
        dot : function (v){
            return this.x * v.x + this.y * v.y + this.z * v.z ;
        },
        cross : function (v){
            return new Engine.Vector3(
                this.y* v.z - this.z * v.y,
                this.z* v.x - this.x * v.z,
                this.x* v.y - this.y * v.x
            );
        },
        multiply : function (n){
            return new Engine.Vector3(this.x* n,this.y* n,this.z* n);
        },
        divide : function (n){
			return new Engine.Vector3(this.x/n,this.y/n,this.z/n);
		}
    };
})();

Engine.Vector3.one = new Engine.Vector3(1,1,1);

